<?php session_start();
include"../admin/conexao.jsp";
require_once("../funcoes/hostel_almoxarifado.jsp");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Mapa</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	
	<script language="javascript" type="text/javascript" src="../css2/form_validator.js"></script>
	<script language="javascript" type="text/javascript" src="../css2/event-listener.js"></script>
	<script language="javascript" type="text/javascript" src="../css2/format-currency.js"></script>
	<script src='../css2/masked-input.js' type='text/javascript'></script>
    <script src='../css2/auto-tab.js' type='text/javascript'></script>
	
	<script language="javascript" type="text/javascript" src="../css2/internal_request.js"></script>
	<script language="javascript" type="text/javascript" src="../css2/calendar/dhtmlgoodies_calendar.js"></script>
	<link rel="stylesheet" type="text/css" href="../css2/css.css">
</head>
<body>
<form action='calcula_lancar_consumo.jsp' method='POST' autocomplete='off' name='frm_consumo' id='frm_consumo'>

<?php
//if ($_POST["acao"] == "lancamento_consumo") {
//	$obs_reserva = "{$_POST["pobs_valor"]} \n";
//print_r($_REQUEST);exit;


if ($_REQUEST["pid_reserva"]) {
	$pid_reserva = $_REQUEST["pid_reserva"];
}else{
	$tp_habitacao = explode("-",$_GET["param1"]);
	$n_hospedes = explode("-",$_GET["param2"]);
	$pid_reserva = $n_hospedes[2];
}

require_once"../funcoes/hostel_reservas.jsp";
getReservas($pid_reserva,"mini_informacoes");

echo "<table width='100%'><tr><td>";

require_once"../funcoes/hostel_valores.jsp";
getValores($pid_reserva,"lista");
$comanda = getValores($pid_reserva,"comanda");

echo"<div id='itens_adicionados'></div></td><td>";

/*
require_once"../funcoes/hostel_almoxarifado.jsp";
$resultado = getEntradaItem($_GET["pobs_valor"],"lista");
$valor = $resultado[2];
echo "$valor";
$teste = "{$_POST["pobs_valor"]} \n";
echo "<br><br>$teste";
*/

##############anterior..no evento onclick##############
/*onclick="<?php 
$resultad = getEntradaItem($_GET["pobs_valor"],"lista"); 
?>
<div class='item'><h5>Valor:</h5><input type='text' name='pvalor' size='9' maxlength='8' value='<?php echo $resultad[2]; ?>'> Exemplo: 2,50</div>">
######################################
*/

// ex-linha abaixo: <input type="hidden" name="pid_reserva2" value="<?php echo $id_reserva; ? >">
?>

<div class='item'><h5>No. da Comanda:</h5><input type='text' name='pnum_comanda' size='4' maxlength='3' value='<?php echo $comanda; ?>'> Utilize No. do quarto  / No. da Comanda</div><br>
<div class='item'><h5>Categoria:</h5>

<select name="pid_hostel_categoria_item" onchange="getConteudo('itens','itens_consumo', document.frm_consumo.pid_hostel_categoria_item.value , 0);">
<option>Selecione uma categoria</option>

<?php
//busca as categorias
require_once("../funcoes/hostel_categoria_item.jsp");
getCategoriaItem(0,"select");
?>
</select><div id="itens"></div><br>

<div id="creditos"></div>
<div class='item'><h5>Opera&ccedil;&atilde;o:</h5><input type='radio' name='poperacao' value='S' onclick="setConteudo('id_senha_gerente','');" checked> D&eacute;bito /<input type='radio' name='poperacao' value='E' onclick="setConteudo('id_senha_gerente','<br><h5>Senha do Gerente:</h5><input type=password name=psenha_gerente size=9 maxlength=8> Somente o gerente pode efetuar lan&ccedil;amento de cr&eacute;dito / desconto<br><br><h5>Valor:</h5><input type=text name=pvalor size=9 maxlength=8> Exemplo: 2,50');"> Cr&eacute;dito / Desconto </div>
<div class='item' id='id_senha_gerente'></div>

<?php
if (getReservas($pid_reserva,"encerrada") == 0) {
	$senha_gerente = $_GET["psenha_gerente"];
	$valor_credito = $_GET["pvalor"];
	echo "<div class='item' align='right'><h5>&nbsp;</h5>
		<input type='button'  value='Efetuar Lan&ccedil;amento' onclick=\"getconteudo2('creditos', 'itens_creditos',document.frm_consumo.psenha_gerente.value + '||'+ document.frm_consumo.pid_reserva.value + '||'+ document.frm_consumo.pnum_comanda.value, document.frm_consumo.pvalor.value);\"></td>		
		</div>";
}else{
	echo"<u>Conta Encerrada!</u>";
}
?>
</form>

</td></tr></table>

<script type="text/javascript">
	//<![CDATA[

	var f = document.getElementById('frm_consumo');
	MaskInput(f.pqtd, "9");

	autoTab(document.getElementById('frm_consumo'));

	formatCurrency(document.forms.frm_consumo.pvalor, 2);

	var valid  = new Validator("frm_consumo");
	valid.addValidation("pobs_valor","alphanumeric");
	valid.addValidation("pobs_valor","req","Descricao");

	valid.addValidation("pqtd","req","Quantidade");
	valid.addValidation("pqtd","numeric");

	valid.addValidation("pvalor","req","Valor");

	//]]>
</script>	